package edu.pku.sei.modeler.uml.commands.umlclass;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.modeler.model.structure.MetaLink;
import edu.pku.sei.modeler.model.structure.MetaNode;
import edu.pku.sei.modeler.model.uml.Kernel.PackageMerge;
import edu.pku.sei.modeler.model.uml.Kernel.UMLPackage;
import edu.pku.sei.modeler.uml.commands.ConnectionModelCreateCommand;
import edu.pku.sei.modeler.uml.commands.UMLConnectionCreateCommand;

public class UMLPackageMergeCreateCommand extends ConnectionModelCreateCommand {


	public UMLPackageMergeCreateCommand(MetaModelElement connectionModel,
			MetaModelElement sourceModel) {
		super(connectionModel, sourceModel);
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean canExecute() {
		if (sourceModel instanceof UMLPackage) {
			return true;
		}else {
			return false;
		}
	}
	
	@Override
	public void undo() {
		PackageMerge packageMerge = (PackageMerge) connectionModel;
		UMLPackage sourcePackage = (UMLPackage) sourceModel;
		sourcePackage.getPackageMerge().remove(packageMerge);

	}

	@Override
	public void execute() {
		PackageMerge packageMerge = (PackageMerge)connectionModel;
//		packageMerge.setModel(this.source.getModelElement().getModel());
		UMLPackage sourcePackage = (UMLPackage) sourceModel;
		sourcePackage.getPackageMerge().add(packageMerge);

	}

}
